package com.example.service;

import com.example.domain.Goods;
import com.example.domain.Option;
import com.example.mapper.GoodsMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsService {

    @Autowired
    private GoodsMapper goodsMapper;

    /**
     * 下拉框数据
     */
    public List<Option> selectGoodsOptions() {
        return goodsMapper.selectGoodsOptions();
    }

    /**
     * 列表
     */
    public PageInfo<Goods> selectGoodsPageList(Goods goods) {
        Integer pageNum = goods.getPageNum();
        PageHelper.startPage(pageNum, 10, true);
        List<Goods> list = goodsMapper.selectList(goods);
        return new PageInfo<>(list);
    }
}
